<template>
	<view class="studentFile">
		<view class="tabs">
			<view class="tabsitem" @click="handleTabs(1)">
				<view :class="currIndex==1 ? 'tabsitemed' :''">
					待办任务
				</view>
				<view v-if="currIndex==1" class="heng"></view>
			</view>
			<view class="tabsitem" @click="handleTabs(2)">
				<view :class="currIndex==2 ? 'tabsitemed' :''">
					已提交
				</view>
				<view v-if="currIndex==2" class="heng"></view>
			</view>
		</view>
		<view class="" style="height: 108rpx;"></view>
		<view v-if="taskLists.length" class="listBox">
			<view class="listitem" v-for="(item,index) in taskLists" @click="handleTaskdetail(item)">
				<view class="topBox">
					<image src="../../static/image/iconfool.png" style="width: 48rpx;height: 48rpx;" mode=""></image>
					<view class="" style="margin-left: 20rpx;">
						任务列表
					</view>
				</view>
				<view class="content">
					<view class="contenttop">
						<view class="lable" style="width: 50%;">
							任务名称
						</view>
						<view class="lable" style="width: 50%;">
							截止时间
						</view>

					</view>
					<view class="contentBottom">
						<view class="value" style="width: 50%;">
							{{item.title}}
						</view>
						<view class="value" style="width: 50%;">
							{{item.end_time}}
						</view>
					</view>

				</view>
				<view class="heng"></view>
				<view class="footerBox">
					<view class="">
						查看详情
					</view>
					<u-icon name="arrow-right-double" color="#CCCCCC" size="20"></u-icon>
				</view>
				
			</view>
		</view>
		
		
		<view v-else class="" style="width:148rpx ;text-align: center;margin: 0 auto;margin-top: 100rpx;">
			<image src="../../static/image/nullimg.png" style="width: 148rpx;height: 148rpx;" mode=""></image>
			<view class="" style="color: #AEB8C2;">
				暂无任务
			</view>
		</view>
		
		<view class="" style="height: 100rpx;"></view>
	</view>
</template>

<script>
	import {
		taskList
	} from "@/api/api.js"
	export default {
		data() {
			return {
				taskLists: [],
				currIndex: 1,
				page: 1,
				page_size: 10,
				pageId:"",
			}
		},
		onLoad(options) {
			
			this.pageId = options.id
			// console.log()
		},
		onShow() {
			this.handletaskList()
		},
		onPullDownRefresh() {
			// console.log("触发了下拉刷新"),
			this.handletaskList()
			uni.stopPullDownRefresh();
		},
		methods: {
			async handletaskList() {
				let data = {
					page: this.page,
					page_size: this.page_size,
					type: this.currIndex,
					id:this.pageId
				}
				let res = await taskList(data)
				this.taskLists = res.data.data
			},
			handleTabs(index) {
				this.currIndex = index
				this.handletaskList()
			},
			handleTaskdetail(item) {
				uni.navigateTo({
					url: `/pages/home/taskDetail?id=${item.id}`
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.studentFile {

		// padding: 30rpx;
		// box-sizing: border-box;
		.tabs {
			width: 100%;
			height: 88rpx;
			background-color: #ffffff;
			display: flex;
			position: fixed;
			top: 0;
			z-index: 9999;

			.tabsitem {
				width: 50%;
				text-align: center;
				line-height: 80rpx;

				.heng {
					width: 50rpx;
					height: 5rpx;
					background-color: #255A9B;
					margin-left: 160rpx;
				}
			}


			.tabsitemed {
				color: #255A9B;
			}

		}

		.listBox {
			width: 690rpx;
			margin: 0 auto;

			.listitem {
				width: 690rpx;
				height: 354rpx;
				background: #FFFFFF;
				border-radius: 16rpx 16rpx 16rpx 16rpx;
				margin-bottom: 30rpx;


				.topBox {
					width: 690rpx;
					height: 92rpx;
					background: #E1E8FD;
					border-radius: 16rpx 16rpx 0 0;
					padding: 22rpx 20rpx;
					box-sizing: border-box;
					display: flex;
					align-items: center;
					font-size: 32rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					color: #255A9B;
					line-height: 32rpx;
				}

				.content {
					padding: 30rpx;
					box-sizing: border-box;

					.contenttop {
						display: flex;
						text-align: center;

						.lable {
							width: 33.33%;
							font-size: 28rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							color: #232832;
							line-height: 36rpx;
						}

					}

					.contentBottom {
						display: flex;
						margin-top: 30rpx;

						.value {
							font-size: 28rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							color: #9E9E9E;
							line-height: 36rpx;
							width: 33.33%;
							text-align: center;
						}
					}
				}

				.heng {
					width: 650rpx;
					height: 1rpx;
					background-color: #F4F4F7;
					margin: 0 auto;
				}

				.footerBox {
					padding: 30rpx 60rpx;
					box-sizing: border-box;
					display: flex;
					align-items: center;
					justify-content: space-between;
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					color: #CCCCCC;
					line-height: 28rpx;
				}

			}
		}

	}
</style>